﻿@namespace MudBlazor.Docs.Examples

<MudDialog>
    <DialogContent>
        <div class="d-flex flex-column py-1">
            <MudButton OnClick="ChangeTitle">Change Title</MudButton>
            <MudButton OnClick="ToggleCloseButton">Toggle Close Button</MudButton>
            <MudButton OnClick="ToggleFullWidth">Toggle Full Width</MudButton>
            <MudButton OnClick="ToggleHeader">Toggle Header</MudButton>
        </div>
    </DialogContent>
    <DialogActions>
        <MudButton Color="Color.Primary" OnClick="Close">Ok</MudButton>
    </DialogActions>
</MudDialog>

@code {
    [CascadingParameter] MudDialogInstance MudDialog { get; set; }

    void Close() => MudDialog.Close(DialogResult.Ok(true));

    void ChangeTitle()
    {
        MudDialog.SetTitle("Current time is: " + DateTime.Now);
    }

    void ToggleCloseButton()
    {
        MudDialog.Options.CloseButton = !(MudDialog.Options.CloseButton ?? false);
        MudDialog.SetOptions(MudDialog.Options);
    }

    void ToggleFullWidth()
    {
        MudDialog.Options.FullWidth = !(MudDialog.Options.FullWidth ?? true);
        MudDialog.SetOptions(MudDialog.Options);
    }

    void ToggleHeader()
    {
        MudDialog.Options.NoHeader = !(MudDialog.Options.NoHeader ?? false);
        MudDialog.SetOptions(MudDialog.Options);
    }
}
